<template>
  <div class="wait_apply_order__container">
    <sl-order-card
      v-for="(item, index) in carOrderListData"
      :key="'car'+ index"
      :current="true"
      :title="item.startName"
      :desc="item.endName"
      :carUserTime="item.carUserTime"
      :price="item.totalAmount"
      :state="item.orderStatus | filterOrderState"
      @click.native="clickFn(item)"
    ></sl-order-card>
    <!--<sl-order-card-->
    <!--v-for="(item, index) in dataList"-->
    <!--:key="index"-->
    <!--:current="item.current"-->
    <!--:title="item.title"-->
    <!--:desc="item.desc"-->
    <!--:small="item.small"-->
    <!--:price="item.price"-->
    <!--:state="item.state"-->
    <!--:source="item.source"-->
    <!--@click.native="clickFn()"-->
    <!--&gt;</sl-order-card>-->
  </div>
</template>

<script>
import slOrderCard from './modules/sl-order-card/sl-order-card'
import { car } from '../data'
export default {
  name: 'wait-order',
  data () {
    return {
      carOrderListData: [],
      dataList: [
        {
          current: true,
          title: '普罗娜商务广场',
          desc: '上海普陀区妇婴保健院',
          small: ['用车时间: 2017-12-19  13:29'],
          price: 23,
          state: '代付款',
          source: '用车'
        },
        {
          current: false,
          title: '上海和平饭店',
          desc: '特色江景套房',
          small: ['入住时间: 2016-09-27 6:00', '离店时间: 2016-09-27 6:00'],
          price: 2000,
          state: '代付款',
          source: '酒店'
        },
        {
          current: false,
          title: '北京-苏州',
          desc: '上海航空FM9158',
          small: ['出发时间: 2016-09-27 6:00'],
          price: 2000,
          state: '代付款',
          source: '机票'
        }
      ]
    }
  },
  mounted () {
    this._getCarOrderList()
  },
  computed: {

  },
  filters: {
    filterOrderState (state) {
      let text = ''
      switch (state) {
      case 'NOT_ORDER':
        text = '未下单'; break
      case 'ORDERING':
        text = '下单中'; break
      case 'ORDERED':
        text = '已下单'; break
      case 'CANCELED':
        text = '已取消'; break
      case 'FINISHED':
        text = '已结束'; break
      default:
        text = '暂无状态'
      }
      return text
    }
  },
  methods: {
    clickFn (item) {
      this.$router.push({
        path: `/carIndex/orderDetail/${item.orderId}`
      })
    },
    // 调用用车订单列表接口
    _getCarOrderList () {
      this.$vux.loading.show({
        text: '加载中...'
      });
      car.getOrderList({}).then((res) => {
        this.$vux.loading.hide();
        if (res.data.code === 0) {
          this.carOrderListData = res.data.data
        }
      })
    }
  },
  components: {
    slOrderCard
  }
}
</script>

<style lang="stylus" type="text/stylus" scoped>
 .wait_apply_order__container
   min-height 100%
</style>
